package cn.javass.dp.observer.example4;

public class WaterQuality extends  WaterQualitySubject {
    //污染级别   0  ，1 ，2
    private  int polluteLevel = 0;

    public void setPolluteLevel(int polluteLevel) {
        this.polluteLevel = polluteLevel;
        this.notifyWatchers();
    }

    @Override
    public int getPolluteLevel() {
        return polluteLevel;
    }

    @Override
    public void notifyWatchers() {
        for (WatcherObserver watcher : observers) {
            if (this.polluteLevel >= 0) {
                if ("监测人员".equals(watcher.getJob())) {
                    watcher.update(this);
                }
            }

            if (this.polluteLevel >= 1) {
                if ("管理人员".equals(watcher.getJob())) {
                    watcher.update(this);
                }
            }

            if (this.polluteLevel >= 2) {
                if ("领导人员".equals(watcher.getJob())) {
                    watcher.update(this);
                }
            }
        }


    }
}
